package com.example.testspringes.jiehun;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.testspringes.sutao.Test2;
import com.example.testspringes.utils.HttpClientUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.Date;
import java.util.Map;

/**
 * @Description: //TODO
 * @ProjectName: testspringes
 * @Package: com.example.testspringes.jiehun
 * @Author: FX
 * @CreateDate: 2019/4/11 14:04
 * @Version: 1.0
 * Copyright: Copyright (c) 2019
 */
@Component
public class Test {

    public static void main(String[] args) throws InterruptedException {
        /*for(int i=0;i<Queue.queue.size();i++){
            String url="http://v.juhe.cn/laohuangli/d?date="+"2019-05-12"+"&key=c973ddcc0f55d9f9596c912acf1c4b07";
            String s = HttpClientUtil.doGet(url, null);
            JSONObject jsonObject = JSON.parseObject(s);
            System.out.println(s);
            Map<String,String> result = (Map<String, String>) jsonObject.get("result");
            if(jsonObject.get("result")!=null){
                String yi = result.get("yi");
                if("嫁娶".contains(yi)){
                    if(i%5==0){
                        Test2.writeFile(s+"\\r\\n");
                    }else{
                        Test2.writeFile(s);
                    }
                }
            }

        }*/
        File writeName = new File(Test2.SUTAO_TXT);
        writeName.delete();
        for(int i=1;i<Queue.queue.size()-1;i++){
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(Queue.queue.take());
            if(i%5==0){
                stringBuilder.append("\r\n");
                Test2.writeFile(stringBuilder.toString());
            }else{
               stringBuilder.append("\t");
                Test2.writeFile(stringBuilder.toString());
            }

        }


    }
}
